[
    async function (kuo, Context, context) {
        Context.headers["content-type"] = 'application/json; charset=UTF-8';
        let LANG = this.LANG();
        let $DATA = Object.assign({}, this.$DATA);
        $DATA.code = -1;
        $DATA.msg = '';
        $DATA.data = [];

        let $Security = await Mem.Get("session/" + kuo.sessionid);
        if (!$Security) {
            $Security = { adminid: 0 };
        }
        if (typeof ($Security['adminid']) == "undefined") {
            $Security['adminid'] = 0;
        }
        if ($Security['adminid'] < 1) {
            $DATA.code = 99;
            $DATA.msg = "Go Login";
            Context.body = JSON.stringify($DATA);
            return;
        }

        let fan = await Mode("admin").Loginok(kuo, $Security);
        if (fan) {
            $DATA.code = fan;
            $DATA.msg = "Error " + kuo.sessionid;
            if ($Security['adminid'] > 0) {
                let $hash = 'safetoken/' + $Security['adminid'];
                $DATA.token = Mode("Tools").Uuid();
                Mem.Set($hash, $DATA.token);
            }
            Context.body = JSON.stringify($DATA);
            return;
        }

        kuo.adminid = $Security['adminid'];
        let $hash = 'safetoken/' + kuo.adminid;
        $DATA.token = Mode("Tools").Uuid();
        Mem.Set($hash, $DATA.token);
        let $kongzhi = kuo.Path[1] ? kuo.Path[1] : "get";
        let $db = await db('apijson_request');
        let $_GET = kuo.get;
        let $_POST = kuo.post;
        let $chushi = true;
        let $features = await Kuoplus(kuo.class);

        if ($kongzhi == 'get') {

            let $page = Mode("Tools").Int($_GET['page'] ? $_GET['page'] : 1);
            let $limitx = Mode("Tools").Int($_GET['limit'] ? $_GET['limit'] : 10);
            if ($limitx < 10) {
                $limitx = 10;
            } else if ($limitx > 100) {
                $limitx = 100;
            }
            let $where = {};

            if (isset($_GET['tags']) && $_GET['tags'] != "") {
                $where['tags'] = $_GET['tags'];
            }

            if (isset($_GET['name']) && $_GET['name'] != "") {
                $where['name'] = $_GET['name'];
            }

            if (isset($_GET['off']) && $_GET['off'] != "") {
                $where['off'] = $_GET['off'];
            }

            let $data = await $db.Where($where).Limit($limitx, $page).Order("id desc").Select();
            let $total = await $db.Where($where).Total();
            if (!$data) {
                $data = [];
            }
            $DATA.code = 0;
            $DATA.count = $total;
            if ($page == 1 && $chushi) {

                $DATA.$BIAODAN = $features['configure']['表单验证'] ? $features['configure']['表单验证'] : [];
                $DATA.$HANSHU = $features['configure']['处理函数'] ? $features['configure']['处理函数'] : [];
                $DATA.$OFF = $features['configure']['状态'] ? $features['configure']['状态'] : ["删除", "关闭", "开启"];
            }

            $DATA.data = $data;



        } else if ($kongzhi == 'put') {

            let $id = Mode("Tools").Int($_POST['id'] ? $_POST['id'] : 0);
            let $data = await $db.Where({ id: $id }).Find();
            if (!$data) {
                $DATA.code = -1;
                $DATA.msg = LANG.admin_id_no;
                Context.body = JSON.stringify($DATA);
                return;
            }

            if ($_POST['method']) {
                let linshi = Object.values($_POST['method'])
                $_POST['method'] = json_encode(linshi);
            } else {
                $_POST['method'] = '[]';
            }

            if ($_POST['structure']) {

                let linshi = Object.values($_POST['structure'])
                $_POST['structure'] = json_encode(linshi);

            } else {
                $_POST['structure'] = '[]';
            }

            $_POST['atime'] = Mode("Tools").Time();
            let $fan = await $db.Where({ id: $id }).Update($_POST);

            if ($fan) {
                this.Rrequest(1);
                await Kuolog('adminlog', kuo.adminid, 3, { 'yuan': $data, 'data': $_POST }, kuo.func_, kuo.class, kuo.ip);
                $DATA.data = $_POST;
                $DATA.code = 1;
                $DATA.msg = LANG.put_ok;
            } else {
                $DATA.code = -1;
                $DATA.msg = LANG.put_no;
            }


        } else if ($kongzhi == 'add') {

            if ($_POST['method']) {
                let linshi = Object.values($_POST['method'])
                $_POST['method'] = json_encode(linshi);
            } else {
                $_POST['method'] = '[]';
            }

            if ($_POST['structure']) {

                let linshi = Object.values($_POST['structure'])
                $_POST['structure'] = json_encode(linshi);

            } else {
                $_POST['structure'] = '[]';
            }


            $_POST['atime'] = Mode("Tools").Time();
            let $fan = await $db.Insert($_POST);

            if ($fan) {
                $DATA.code = 1;
                $DATA.msg = LANG.add_ok;
                this.Rrequest(1);
                await Kuolog('adminlog', kuo.adminid, 4, $_POST, kuo.func_, kuo.class, kuo.ip);
            } else {
                $DATA.code = -1;
                $DATA.msg = LANG.add_no;
            }

        } else if ($kongzhi == 'del') {

            let $id = Mode("Tools").Int($_POST['id'] ? $_POST['id'] : 0);
            let $data = await $db.Where({ id: $id }).Find();

            if (!$data) {
                $DATA.code = -1;
                $DATA.msg = LANG.admin_id_no;
                Context.body = JSON.stringify($DATA);
                return;
            }

            let $fan = await $db.Where({ id: $id }).Delete();

            if ($fan) {
                this.Rrequest(1);
                await Kuolog('adminlog', kuo.adminid, 5, $data, kuo.func_, kuo.class, kuo.ip);
                $DATA.code = 1;
                $DATA.msg = LANG.del_ok;
            } else {
                $DATA.code = -1;
                $DATA.msg = LANG.del_no;
            }
        }


        Context.body = json_encode($DATA);
    }

]